﻿@using RiderShop.Mobile.Common.Component
@section title
{
鲜享卡/银信商通卡修改密码
}
@section pagetitle
{
鲜享卡/银信商通卡修改密码
}

@section header
{
    <link rel="stylesheet" href="~/Themes/RongJi/Style/base/css/sign.css?v=1">
    <style>
        .body {
            margin-top: 10%;
        }

        .amount {
            margin-top: 20px;
            text-align: center;
            font-size: 16px;
        }

        .btn-green {
            background: #79c9a5;
        }
    </style>
}

<div class="box">
    <div class="top">
        <img src="~/Themes/RongJi/Style/base/imgs/card.jpg" alt="">
    </div>

    <form action="~/Purchase/YinxinBalance" method="POST" id="yixinPayModifyPasswordForm">
        <div class="body">
            <input type="text" class="form-control" id="cardNumber" name="cardNumber" maxlength="30" placeholder="请输入卡号">
            <input type="password" class="form-control" id="oldPassword" name="oldPassword" placeholder="请输入老密码" maxlength="20" autocomplete="off">
            <input type="password" class="form-control" id="newPassword" name="newPassword" placeholder="请输入新密码" maxlength="20" autocomplete="off">
            <input type="password" class="form-control" id="newConfirmPassword" name="newConfirmPassword" placeholder="请确认新密码" maxlength="20" autocomplete="off">

            <span class="err_msg" id="msgError"></span>
        </div>
        <div class="bottom">
            <div class="btn-group btn-group-justified btn-wrapper" role="group" aria-label="...">
                <div class="btn-group" role="group">
                    <input type="button" id="btnyixinModifyPassword" class="btn" value="修改密码">
                </div>
            </div>
        </div>
    </form>
</div>

@section footer
{
    <script type="text/javascript">
        $(function () {
            var cardNumber = $.cookie('xxCardNumber');
            if (cardNumber) {
                $("#cardNumber").val(cardNumber);
            }
        });

        //修改密码
        $("#btnyixinModifyPassword").click(function () {
            if ($.trim($("#cardNumber").val()) == "") {
                KevinShop.MessageBox.Alert("请输入卡号!");

                return false;
            }
            if ($.trim($("#oldPassword").val()) == "") {
                KevinShop.MessageBox.Alert("请输入老密码!");

                return false;
            }

            if ($.trim($("#newPassword").val()) == "") {
                KevinShop.MessageBox.Alert("请输入新密码!");

                return false;
            }

            if ($.trim($("#newConfirmPassword").val()) == "") {
                KevinShop.MessageBox.Alert("请输入再输入新密码!");

                return false;
            }

            if ($("#newConfirmPassword").val() != $("#newPassword").val()) {
                KevinShop.MessageBox.Alert("两次密码不一致!");

                return false;
            }

            if (!window.confirm('你确定要改变密码吗？')) {
                return false;
            }


            $.cookie('xxCardNumber', $("#cardNumber").val());

            var postdata = $("#yixinPayModifyPasswordForm").serialize();
            //document.forms["yixinPayForm"].submit();
            var loadMark = KevinShop.Common.Loading;
            $.ajax({
                type: "post",
                url: '/Purchase/YinxinModifyPassword',
                data: postdata,
                contentType: "application/x-www-form-urlencoded; charset=utf-8",
                beforeSend: function (XMLHttpRequest) {
                    loadMark.show();
                    $("#msgError").html("正在提交，请稍等。");
                },
                success: function (response) {
                    if (response.Status == false && response.ErrorMessage != '') {
                        $("#msgError").html(response.ErrorMessage);

                        return false;
                    }
                    else if (response.Status == true && response.ErrorMessage == '') {
                        $("#msgError").html('修改成功！');

                        return true;
                    }
                },
                complete: function (XMLHttpRequest, textStatus) {
                    //HideLoading();
                    loadMark.hide();
                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    //请求出错处理
                    $("#msgError").html("服务器异常，请刷新页面重试！");
                    loadMark.hide();
                }
            });
        });
    </script>
}
